package com.maxjay.component.simplelist.model;

import java.util.ArrayList;
import java.util.List;

import com.maxjay.component.metadata.model.Entity;
import com.maxjay.system.core.Application;

public class DefaultQueryScheme implements QueryScheme {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3635963650847583920L;
	
	/**
	 * 查询方案ID
	 */
	private String id;
	
	/**
	 * 查询方案名称
	 */
	private String name;
	
	/**
	 * 查询方案实体ID
	 */
	private String entityId;
	
	/**
	 * 查询条件字段
	 */
	private List<QueryConditionField> conditionFields = new ArrayList<QueryConditionField>();
	
	/**
	 * 查询列表显示字段
	 */
	private List<QueryListField> listFields = new ArrayList<QueryListField>();
	
	/**
	 * 查询方案配置信息
	 */
	private QuerySchemeConfig querySchemeConfig;

	public DefaultQueryScheme(String id, String name) {
		this.id = id;
		this.name = name;
	}
	
	public DefaultQueryScheme(String id, String name, String entityId) {
		this.id = id;
		this.name = name;
		this.entityId = entityId;
	}
	
	@Override
	public String getId() {
		return id;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public Entity getEntity() {
		return Application.getEntityContext().getEntityFactory().getEntity(entityId);
	}

	@Override
	public void addConditonField(QueryConditionField queryField) {
		this.conditionFields.add(queryField);
	}

	@Override
	public void addListField(QueryListField queryListField) {
		this.listFields.add(queryListField);
	}

	@Override
	public List<QueryListField> getListFields() {
		return listFields;
	}

	@Override
	public List<QueryConditionField> getConditionFields() {
		return conditionFields;
	}

	@Override
	public QuerySchemeConfig getQuerySchemeConfig() {
		return querySchemeConfig;
	}

	public void setQuerySchemeConfig(QuerySchemeConfig querySchemeConfig) {
		this.querySchemeConfig = querySchemeConfig;
	}
	
}